package com.yulongtian.oneProblemEveryDay.month202301;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.cn/problems/check-if-numbers-are-ascending-in-a-sentence/
 *
 * @author yulongTian
 * @create 2023-01-03 18:42
 */
public class Test02 {
    public static void main(String[] args) {
        System.out.println(areNumbersAscending("hello world 5 x 5"));
    }

    public static boolean areNumbersAscending(String s) {
        String[] split = s.split(" ");

        List<Integer> nums=new ArrayList<>();
        for (String s1 : split) {
            if(s1.charAt(0)>='0'&&s1.charAt(0)<='9'){
                nums.add(Integer.valueOf(s1));
            }
        }

        for (int i = 1; i < nums.size(); i++) {
            if(nums.get(i)<=nums.get(i-1)){
                return false;
            }
        }

        return true;
    }

}
